<?php 
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{

	public function index () {
		$this->display(':login');
	}

	public function LoginHalt () {
		if (I('username') && I('pwd')) {
			
			if ($ret = M('admin')->where(array('username'=>I('username')))->find()) {
				if ($ret['password'] == I('pwd','','md5')) {
					
					if ($ret['status'] == 1) {
						
						$_SESSION['uid'] = $ret['id'];
						$_SESSION['name'] = $ret['username'];
						$data['logintime'] = time();
						$data['loginip'] = get_client_ip();
						$data['id'] = $ret['id'];
						M('admin')->save($data);
						$this->success('登陆成功!',U('Index/index'));
					}else{
						$this->error('用户被冻结,请联系管理员!');
					}


				}else{
					$this->error('密码错误!');
				}
			}else{
				$this->error('没有该用户!');
			}

		}else{
			$this->error('用户名或密码不能为空!');
		}
	}


	public function logout () {
		session('uid',null);
		session('name',null);
		session('[destroy]');
		$this->redirect('/Admin/Login/index');
	}

}





 ?>